import request from "@/utils/request";
import { AxiosPromise } from "axios";
import {
  IDeptQueueUserInfo,
  ICheckProject,
  IDashBoard,
  IDeptQueueVo,
  IAwaitQueueDetailVo,
} from "./types";

/**
 *医生负责的科室排队人数信息
 */
export function deptQueueUserInfoAPI(): AxiosPromise<IDeptQueueUserInfo> {
  return request({
    url: "/queue/doctor/dept/users",
    method: "get",
  });
}

/**
 *医生负责的科室和同级科室排队情况
 */
export function queueDeptORSiblingByDoctorAPI(): AxiosPromise<
  IDeptQueueUserInfo[]
> {
  return request({
    url: "/queue/doctor/deptORSibling/users",
    method: "get",
  });
}

/**
 *根据科室Id查询 同级科室排队信息
 */
export function queueDeptORSiblingByDeptIdAPI(
  deptId?: number
): AxiosPromise<IDeptQueueUserInfo[]> {
  return request({
    url: `/queue/doctor/deptORSibling/users/${deptId}`,
    method: "get",
  });
}

/**
 *  完成项目检查
 */
export function finfishProjectAPI(userId: number, deptId: number) {
  return request({
    url: "/queue/finished",
    method: "get",
    params: {
      userId: userId,
      deptId: deptId,
    },
  });
}

/**
 * 取消项目检查
 */
export function cancelProjectAPI(userId: number, deptId: number) {
  return request({
    url: "/queue/cancel",
    method: "get",
    params: {
      userId: userId,
      deptId: deptId,
    },
  });
}

/* 当前用户排队项目 */
export function QueryUserProject(
  userId?: number
): AxiosPromise<ICheckProject[]> {
  return request({
    url: `/queue/project`,
    method: "get",
    params: {
      userId: userId,
    },
  });
}

/* 用户参与体检项目 */
export function AssignProject() {
  return request({
    url: `/queue/assign`,
    method: "post",
  });
}

/* 用户排队 */
export function queueProject(deptId: number, userId?: number) {
  return request({
    url: `/queue/rank`,
    method: "get",
    params: {
      deptId: deptId,
      userId: userId,
    },
  });
}
/* 所有项目排队人数及项目信息 */
export function queryAllProjectQueue() {
  return request({
    url: `/queue/dept/queryAllProjectQueue`,
    method: "get",
  });
}

/* 用户取消自己排队 */
export function cancelUserQueue(projectId: number) {
  return request({
    url: `/queue/user/cancel`,
    method: "get",
    params: {
      projectId: projectId,
    },
  });
}

/* 插队 */
export function insertQueueAPI(
  currentDeptId?: number,
  targetDeptId?: number,
  currentUserId?: number,
  targetUserId?: number
) {
  return request({
    url: `/queue/insert`,
    method: "get",
    params: {
      currentDeptId: currentDeptId,
      targetDeptId: targetDeptId,
      currentUserId: currentUserId,
      targetUserId: targetUserId,
    },
  });
}

/* 首页数据 */
export function getDashboardData(): AxiosPromise<IDashBoard> {
  return request({
    url: `/queue/getDashboardData`,
    method: "get",
  });
}

export function queryRecommendProject(): AxiosPromise<ICheckProject> {
  return request({
    url: `/queue/recommend`,
    method: "post",
  });
}

/* 获取各个科室排队信息 */
export function getAllQueueListAPI(): AxiosPromise<IDeptQueueVo[]> {
  return request({
    url: `/queue/all/queues`,
    method: "get",
  });
}

/* 根据deptId获取 科室排队信息 */
export function getDeptQueueListAPI(
  deptId: number
): AxiosPromise<IDeptQueueUserInfo> {
  return request({
    url: `/queue/${deptId}/queueDetail`,
    method: "get",
  });
}

/*  获取病人待检测项目信息 */
export function awaitQueueUserListAPI(): AxiosPromise<IAwaitQueueDetailVo[]> {
  return request({
    url: `/queue/await/queueUsers`,
    method: "get",
  });
}
